package com.youle.contoller;

import com.youle.enums.ExceptionEnum;
import com.youle.exception.YLException;
import com.youle.service.SpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by
 * 负责规格参数模板的curd操作      as: http://api.leyou.com/api/item/spec/groups/3
 * @author touni
 * @date 2019/4/23
 * @time 12:56
 */
@RestController
@RequestMapping("spec")
public class SpecificationController {


    @Autowired
    private SpecificationService specificationService;

    /**
     * 展示根据cid查询到模板    前端无法正常显示 todo
     * @param cid
     * @return
     */
    @RequestMapping("groups/{cid}")
    public ResponseEntity listSpecificationByCid(@PathVariable Long cid){
        if (null == cid){ throw new YLException(ExceptionEnum.PARAM_NOT_BE_NULL);}
        return specificationService.listSpecificationByCid(cid);
    }



}
